//
//  XMTableViewCollectionCell.m
//  XMFriendCircleDemo
//
//  Created by chenming on 2018/1/28.
//  Copyright © 2018年 ChenXiaoMing. All rights reserved.
//

#import "XMTableViewCollectionCell.h"

@interface XMTableViewCollectionCell ()

@end

@implementation XMTableViewCollectionCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self.contentView addSubview:self.cellImageView];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.cellImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
}

- (void)setPicImageArray:(NSArray *)picImageArray {
    _picImageArray  = picImageArray;
    for (NSString *imageStr in picImageArray) {
        if ([imageStr hasPrefix:@"http"]) {
            [self.cellImageView sd_setImageWithURL:[NSURL URLWithString:imageStr] placeholderImage:nil];
        }
    }
}

- (UIImageView *)cellImageView {
    if (!_cellImageView) {
        _cellImageView = [[UIImageView alloc] init];
        _cellImageView.backgroundColor = [UIColor xm_randomColor];
        _cellImageView.contentMode = UIViewContentModeScaleAspectFill;
        _cellImageView.clipsToBounds = YES;
    }
    return _cellImageView;
}

@end
